# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=ocaml-perl-bridge
pkgver=0.01
pkgrel=4
_gitrev=611f632429f4e70508db4a921fea4b13b8e57161
pkgdesc="Perl embedded in OCaml"
url="https://github.com/stevan/ocaml-perl-bridge"
arch="all !riscv64 !loongarch64" # ocaml
license="LGPL-2.0-or-later"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="ocaml perl-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/stevan/ocaml-perl-bridge/archive/$_gitrev.tar.gz
	makefile-site-lib.patch
	ocaml-headers-path.patch
	ocaml-preprocessor-macros.patch
	perl-SVt_RV-missing.patch
	"
builddir="$srcdir/$pkgname-$_gitrev"

build() {
	make
	make opt
}

package() {
	make DESTDIR="$pkgdir" install
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\) | while read -r path
	do
		amove "$path"
	done
}

prepare_py_provides() {
	local datadir="${subpkgdir:-$pkgdir}"
	local pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
	local controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}

	options_has "!tracedeps" && return 0

	ocaml4-abuild-find provides \
		"$datadir"/usr/lib/ocaml \
		"$controldir" \
		"$pkgver-r$pkgrel"
}

scan_python3_dependency() {
	local controldir="$2" datadir="$3"

	ocaml4-abuild-find requires \
		"$datadir"/usr/lib/ocaml \
		"$controldir"
}

sha512sums="
3d7df4b7e93bad7fc6173804d3828276f6be526a6bdea6f8ff595d56ed3b6d53b8b926cf7c11f7abff7420fd47505f9e8c8f88a2c69951be3001ef3072f4fdf3  ocaml-perl-bridge-0.01.tar.gz
d09f7f33886d235078353626b659340070859b5591e088555ddf4c0d1eb71f717ded18876d1811bc3db260742365c0b0581b9320721e8d13c0997a98270ae6f3  makefile-site-lib.patch
514681b9d4a0c1c737a61e9cd225cedc0850e94555b3c4f8ec7a4aecd610ccd411d0ee24c32347c263064138017f672caa76ad27597367efe7fd23dbd8a4f80c  ocaml-headers-path.patch
a7d385682902c48ff49bac77170f8d41376897f7d9056a49b97457d1895839496f706ecfbe93db9ea1f6dfc10fbebaa75a8d07c25d0265e168866f43bdef1408  ocaml-preprocessor-macros.patch
ec916fd8115a2bfe1f05cd7bd15bc7ad8125dd7c6da7ee9e9cb97bd2c4ebd4e7f84df8f2564c7fd79e4da25b5727d72a2dbd03e7d933773dd5715707178661c9  perl-SVt_RV-missing.patch
"
